<script setup lang="ts">
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'
const charts = ref()
onMounted(() => {
  let myCharts = echarts.init(charts.value)
  myCharts.setOption({
    xAxis: {
      type: 'category',
      boundaryGap: false,
      splitLine: {
        show: false,
      },
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
      axisLine: {
        show: true,
      },
      axisTick: {
        show: true,
      },
    },
    yAxis: {
      splitLine: {
        show: false,
      },
      axisLine: {
        show: true,
      },
      axisTick: {
        show: true,
      },
    },
    series: [
      {
        type: 'line',
        data: [100, 1200, 89, 800, 1600, 100, 2000],
        smooth: true,
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: '#7c6234', // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#2c2e4c', // 100% 处的颜色
              },
            ],
            global: false, // 缺省为 false
          },
        },
      },
    ],
    grid: {
      left: 40,
      top: 0,
      right: 0,
      bottom: 20,
    },
  })
})
</script>

<template>
  <div class="sex">
    <div class="title">
      <p>年龄比例</p>
      <div class="img"></div>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<style scoped lang="scss">
.sex {
  height: 100%;
  background: url('../images/dataScreen-main-cb.png') no-repeat;
  background-size: cover;
  color: white;
  position: relative;
  .title {
    font-size: 24px;
  }
  .img {
    width: 68px;
    height: 7px;
    background: url('../images/dataScreen-title.png') no-repeat;
    background-size: cover;
    margin-top: 8px;
  }
  .charts {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 75%;
  }
}
</style>
